/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package answerquestion_simple;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import java.util.*;
/**
 *
 * @author Huynh Ngoc Khue
 */
public class Parser {

    String STR_COLECTTION_WORD;// list result form stanford parser: STR_COLECTION_WORD
    public Parser()
    {
        this.STR_COLECTTION_WORD = "";
    }
   
    public void MakeParser(String rSentence)
    {
        this.STR_COLECTTION_WORD = "";
        String[] rlistWord = rSentence.split(" ");
        LexicalizedParser lp = new LexicalizedParser("englishPCFG.ser");
        lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"});
        Tree parse = (Tree) lp.apply(Arrays.asList(rlistWord));
        //parse.pennPrint();

        TreebankLanguagePack tlp = new PennTreebankLanguagePack();
        GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
        GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
        Collection tdl = gs.typedDependencies();
        this.STR_COLECTTION_WORD = tdl.toString();
    }
    public String getResult()
    {
        return this.STR_COLECTTION_WORD;
    }
}
